package com.sneaker.shower.entity.dto;

import com.sneaker.shower.entity.domain.order.PayOrderDO;
import com.sneaker.shower.entity.domain.order.SubOrderDO;
import com.sneaker.shower.entity.domain.user.UserDO;
import com.sneaker.shower.entity.domain.user.UserLevelDO;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Hechangjian
 * @version 1.0
 * @className WxPayParamDTO
 * @date 2019/10/15 15:24
 * @description 微信支付相关参数
 * @program bath
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel("微信支付的相关参数")
public class WxPayParamDTO {
    String payGuid;

    Integer payOrderVersion;

    Integer userLevelVersion;

    String userLevelGuid;

    String userGuid;

    Integer userVersion;

    String subOrderGuid;

    Integer subOrderVersion;

    public static WxPayParamDTO INSTANCE(PayOrderDO payOrderDO, UserLevelDO userLevelDO, UserDO userDO, SubOrderDO subOrderDO) {
        WxPayParamDTO wxPayParamDTO = new WxPayParamDTO();
        if (payOrderDO != null) {
            wxPayParamDTO.setPayGuid(String.valueOf(payOrderDO.getGuid()));
            wxPayParamDTO.setPayOrderVersion(payOrderDO.getVersion());
        }
        if (userDO != null) {
            wxPayParamDTO.setUserGuid(String.valueOf(userDO.getGuid()));
            wxPayParamDTO.setUserVersion(userDO.getVersion());
        }
        if (userLevelDO != null) {
            wxPayParamDTO.setUserLevelGuid(String.valueOf(userLevelDO.getGuid()));
            wxPayParamDTO.setUserLevelVersion(userLevelDO.getVersion());
        }
        if (subOrderDO != null) {
            wxPayParamDTO.setSubOrderGuid(String.valueOf(subOrderDO.getGuid()));
            wxPayParamDTO.setSubOrderVersion(subOrderDO.getVersion());
        }
        return wxPayParamDTO;
    }
}
